package kr.bae.androidcomplete01.chapter07;

import kr.bae.androidcomplete01.R;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.RadialGradient;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class ShapeDrawbaleEx extends Activity {
	Button lBtn;
	Button cBtn;
	Button rBtn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch07_shapedrawableex);

		lBtn = (Button) findViewById(R.id.ch07_leftbtn);
		cBtn = (Button) findViewById(R.id.ch07_centerbtn);
		rBtn = (Button) findViewById(R.id.ch07_rightbtn);
	}

	public void mOnClick(View v) {
		switch (v.getId()) {
		case R.id.ch07_leftbtn:
			lBtn.setBackgroundResource(R.drawable.shape2);

			break;
		case R.id.ch07_centerbtn:
			cBtn.setBackgroundResource(R.drawable.shape3);
			break;

		case R.id.ch07_rightbtn:
			ShapeDrawable sd = new ShapeDrawable(new OvalShape());
			sd.getPaint().setShader(
					new RadialGradient(60, 30, 50, Color.WHITE, Color.BLACK,
							TileMode.CLAMP));
			rBtn.setBackground(sd);
			break;

		default:
			break;
		}
	}
}
